#!/bin/bash
# 数据库备份脚本

BACKUP_DIR="/backups/musicdb"
DATE=$(date +%Y%m%d)
DEST="$BACKUP_DIR/backup-$DATE.sqlite"

# 使用SQLCipher导出
sqlite3 /data/music.db ".backup $DEST"

# 保留最近7天备份
find $BACKUP_DIR -name "backup-*.sqlite" -mtime +7 -exec rm {} \;

# 上传到云端
aws s3 cp $DEST s3://musicdb-backups/